package com.xbongbong.pro.message.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * 新工单消息推送类型枚举
 *
 * @author LiZhikang
 * @date 2022/10/27 18:03
 */
@Getter
@AllArgsConstructor
public enum WorkOrderV2PushTypeEnum {
    /**
     * 新工单消息推送类型枚举
     */
    WORK_ORDER_V2(0, 0, "workOrderV2", null, null, 0),
    WORK_ORDER_V2_ADD(1, 1, "workOrderV2Add", "enum.workOrderV2PushType.title.add", "enum.workOrderV2PushType.content.add", 0),
    WORK_ORDER_V2_ALLOCATE(2, 1, "workOrderV2Allocate", "enum.workOrderV2PushType.title.allocate", "enum.workOrderV2PushType.content.allocate", 0),
    WORK_ORDER_V2_TRANSFER(3, 1, "workOrderV2Transfer", "enum.workOrderV2PushType.title.transfer", "enum.workOrderV2PushType.content.transfer", 0),
    WORK_ORDER_V2_TEAM(4, 1, "workOrderV2Team", "enum.workOrderV2PushType.title.team", "enum.workOrderV2PushType.content.team", 0),
    WORK_ORDER_V2_DELETE(5, 1, "workOrderV2Delete", "enum.workOrderV2PushType.title.delete", "enum.workOrderV2PushType.content.delete", 0),
    WORK_ORDER_V2_ABNORMAL(6, 1, "workOrderV2Abnormal", "enum.workOrderV2PushType.title.abnormal", "enum.workOrderV2PushType.content.abnormal", 0),
    WORK_ORDER_V2_RECEIVE(7, 2, "workOrderV2Receive", "enum.workOrderV2PushType.title.receive", "enum.workOrderV2PushType.content.receive", 0),
    WORK_ORDER_V2_START(8, 2, "workOrderV2Start", "enum.workOrderV2PushType.title.start", "enum.workOrderV2PushType.content.start", 0),
    WORK_ORDER_V2_FINISH(9, 2, "workOrderV2Finish", "enum.workOrderV2PushType.title.finish", "enum.workOrderV2PushType.content.finish", 0),
    WORK_ORDER_V2_CANCEL(10, 2, "workOrderV2Cancel", "enum.workOrderV2PushType.title.cancel", "enum.workOrderV2PushType.content.cancel", 0),
    WORK_ORDER_V2_SETTLE(11, 2, "workOrderV2Settle", "enum.workOrderV2PushType.title.settle", "enum.workOrderV2PushType.content.settle", 0),
    WORK_ORDER_V2_VISIT(12, 2, "workOrderV2Visit", "enum.workOrderV2PushType.title.visit", "enum.workOrderV2PushType.content.visit", 0),
    WORK_ORDER_V2_GRAB(13, 2, "workOrderV2Grab", "enum.workOrderV2PushType.title.grab", "enum.workOrderV2PushType.content.grab", 0),
    WORK_ORDER_V2_RESTART(14, 2, "workOrderV2Restart", "enum.workOrderV2PushType.title.restart", "enum.workOrderV2PushType.content.restart", 0),
    WORK_ORDER_V2_BACK(15, 2, "workOrderV2Back", "enum.workOrderV2PushType.title.back", "enum.workOrderV2PushType.content.back", 0),
    WORK_ORDER_V2_REFUSE(16, 2, "workOrderV2Refuse", "enum.workOrderV2PushType.title.refuse", "enum.workOrderV2PushType.content.refuse", 0);

    /**
     * 推送子类型
     */
    private final Integer subCode;

    /**
     * 分类
     */
    private final Integer module;

    /**
     * 别名
     */
    private final String alias;

    /**
     * 标题
     */
    private final String title;

    /**
     * 内容
     */
    private final String content;

    /**
     * 是否实时推送
     */
    private final Integer isRealTime;

    public static WorkOrderV2PushTypeEnum getBySubCode(Integer subCode) {
        for (WorkOrderV2PushTypeEnum pushTypeEnum : values()) {
            if (pushTypeEnum.getSubCode().equals(subCode)) {
                return pushTypeEnum;
            }
        }
        return WORK_ORDER_V2;
    }

    public static List<Integer> getPushSubCodeList() {
        List<Integer> subCodes = new ArrayList<>();
        for (WorkOrderV2PushTypeEnum workOrderV2PushTypeEnum : values()) {
            subCodes.add(workOrderV2PushTypeEnum.getSubCode());
        }
        return subCodes;
    }

    public String getTitle() {
        return I18nMessageUtil.getMessage(title);
    }

    public String getContent() {
        return I18nMessageUtil.getMessage(content);
    }

}
